﻿//***************************************************************************//
//                                                                           //
//Author:       Kris Henry                                                   //
//Class Name:   OptionsState.cs                                              //
//Pupose:       Handle the drawing and input for the intro page to the game  //
//              ingame options                                               //
//Date :        December 2012                                                //
//                                                                           //
//***************************************************************************//

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;


namespace Indie_Game_Contest
{
    class IntroState : IGameState
    {
        int IntroFont;
        int GossipFont;

        public int GossipFont1
        {
            get { return GossipFont; }
            set { GossipFont = value; }
        }
        int cats;
        int posX, posY;
        Vector2 pos;
        bool flip;

        public bool Flip
        {
            get { return flip; }
            set { flip = value; }
        }
        CatAnimations cat;
        float rot;
        int counter;
        
        KeyboardState keys, prevkeys;
        GamePadState stick, prevstick;
        private static IntroState instance;

        int intro_background;

        public int Intro_background
        {
            get { return intro_background; }
            set { intro_background = value; }
        }
        public Vector2 Pos
        {
            get { return pos; }
            set { pos = value; }
        }
        public float Rot
        {
            get { return rot; }
            set { rot = value; }
        }

        public int Cats
        {
            get { return cats; }
            set { cats = value; }
        }
        public CatAnimations Cat
        {
            get { return cat; }
            set { cat = value; }
        }
        public static IntroState Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new IntroState();
                }
                return instance;
            }
        }
        public int IntroFont1
        {
            get { return IntroFont; }
            set { IntroFont = value; }
        }
        override public void Update(float dt)
        {
            Cat.Update(10);
            if (counter % 20 == 0)
            {
                Rot += 0.01f;
            }
            counter++;
        }
        override public bool Input()
        {
           keys = Keyboard.GetState();
           stick  = GamePad.GetState(PlayerIndex.One);

           if (CInput.Instance.KeyPressed(Keys.Enter) || CInput.Instance.GamePadButtonPressed(Buttons.Start))
            {

                Game1.Instance.AddState(MainMenuSate.Instance);
                Game1.Instance.RemoveState(this);
               
                return true;
            }

            if (CInput.Instance.KeyDown(Keys.Left))
            {
                posX--;             
                flip = true;               
            }
            if (CInput.Instance.KeyDown(Keys.Right))
            {
                posX++;
                if (flip)
                {
                    flip = false;                    
                }                
            }
            prevstick = stick;
            prevkeys = keys;
            
            Pos = new Vector2(posX, posY);
            return true;
        }
        override public void Render()
        {
            Rectangle source = new Rectangle(0, 0, TextureManager.Instance.GetTexture(Intro_background).Width, TextureManager.Instance.GetTexture(Intro_background).Height);
            Rectangle dest =new Rectangle(0, 0, WorldData.WindowWidth, WorldData.WindowHeight);
            Vector2 origin = new Vector2(dest.Center.X,dest.Center.Y);
            WorldData.spriteBatch.Draw(TextureManager.Instance.GetTexture(Intro_background),new Vector2(0,0),source, Color.White,Rot,origin,5.0f,SpriteEffects.None,1);
            WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(IntroFont1), "Gossip!: ", new Vector2(600, 425), Color.White, 0.0f, new Vector2(250, 250), 1.0f, SpriteEffects.None, 1);
            WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(MainMenuSate.Instance.MenuFont1), "The Musical", new Vector2(300, 200), Color.White);
            WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(MainMenuSate.Instance.MenuFont1), "Beat'em Up Experience", new Vector2(200, 225), Color.White);

 
            WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(MainMenuSate.Instance.MenuFont1), "Press Enter or Start", new Vector2(225, 300), Color.White);
            //Cat.Draw(WorldData.spriteBatch, Pos, new Vector2(0, 3),0.0f,5.0f,flip);
        }
        override public void Enter()
        {
          
            Pos = new Vector2(150, 150);
            Rot = 0.0f;
            posX = 30;
            posY = 50;
           
        }
        override public void Exit()
        {
            
        }
    }
}
